<fieldset>
    <legend>条件搜索</legend>
    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">微信昵称</label>
            <label class="layui-input-inline">
                <input name="nickname" value="{$get.nickname|default=''}" placeholder="请输入微信昵称" class="layui-input">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">订阅状态</label>
            <label class="layui-input-inline">
                <select class="layui-select" name="subscribe">
                    <option value=''>-- 全部 --</option>
                    {foreach ['显示未订阅的粉丝','显示已订阅的粉丝'] as $k=>$v}
                    {if isset($get.subscribe) and $get.subscribe eq $k.""}
                    <option selected value="{$k}">{$v}</option>
                    {else}
                    <option value="{$k}">{$v}</option>
                    {/if}{/foreach}
                </select>
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">拉黑状态</label>
            <label class="layui-input-inline">
                <select class="layui-select" name="is_black">
                    <option value=''>-- 全部 --</option>
                    {foreach ['显示未拉黑的粉丝','显示已拉黑的粉丝'] as $k=>$v}
                    {if isset($get.is_black) and $get.is_black eq $k.""}
                    <option selected value="{$k}">{$v}</option>
                    {else}
                    <option value="{$k}">{$v}</option>
                    {/if}{/foreach}
                </select>
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">订阅时间</label>
            <label class="layui-input-inline">
                <input data-date-range name="subscribe_at" value="{$get.subscribe_at|default=''}" placeholder="请选择订阅时间" class="layui-input">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            <button type="button" data-form-export="{:url('index')}?type={$type|default=''}" class="layui-btn layui-btn-primary">
                <i class="layui-icon layui-icon-export"></i> 导 出
            </button>
        </div>
    </form>
</fieldset>

<script>
    window.form.render();
    require(['excel'], function (excel) {
        excel.bind(function (data, sexs) {
            sexs = {1: '男', 2: '女'};
            data.forEach(function (item, index) {
                data[index] = [
                    item.openid || '',
                    item.nickname || '',
                    item.country || '',
                    item.province || '',
                    item.city || '',
                    sexs[item.sex] || '未知',
                    item.subscribe ? '已订阅' : '未订阅',
                    item.subscribe_at || '',
                    item.is_black ? '已拉黑' : '未拉黑',
                ];
            });
            data.unshift(['OPENID', '微信昵称', '所在国家', '所在省份', '所在城市', '性别', '订阅状态', '订阅时间', '是否拉黑']);
            return data;
        }, '微信粉丝数据');
    });
</script>